﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using CinemaDbLib;
using ModelLayer;

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ReservationCtrl" in code, svc and config file together.
public class ReservationCtrl : IReservationCtrl
{
	private ReservationDB reservationDB;

	public ReservationCtrl()
	{
		reservationDB = new ReservationDB();
	}

	public int addReservation(string name, string phoneNr, Ticket ticket)
	{
		Reservation reservation = new Reservation(-1, name, phoneNr, ticket);
		return reservationDB.insertReservation(reservation);
	}

	public bool removeReservation(int id)
	{
		return reservationDB.removeReservation(id);
	}

	public bool updateReservation(int id, string name, string phoneNr, 
		Ticket ticket)
	{
		Reservation reservation = new Reservation(id, name, phoneNr, ticket);
		return reservationDB.updateReservation(reservation);
	}

	public Reservation getReservationById(int id)
	{
		return reservationDB.getReservationById(id);
	}

	public Reservation getReservationByTicket(int ticketId)
	{
		return reservationDB.getReservationByTicket(ticketId);
	}

	public Reservation[] getReservations()
	{
		return reservationDB.getReservations().ToArray();
	}
}
